package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.RoleQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lrc.request.*;
import com.ssy.lingxi.member.merchant.model.vo.lrc.response.*;
import com.ssy.lingxi.member.merchant.service.web.IMemberLevelConfigService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台后台 - 平台会员升级规则、等级、权益相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2020-08-24
 */
@RestController
@RequestMapping("/member/manage")
public class PlatformMemberLevelRightCreditServiceController {
    @Resource
    private IMemberLevelConfigService memberLevelConfigService;

    /**
     * 分页查询会员升级规则
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/rule/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberLevelRuleConfigQueryVO>> pageMemberLevelRuleConfig(@RequestHeader HttpHeaders headers, @Valid PageVO pageVO) {
        return memberLevelConfigService.pageMemberLevelRuleConfig(headers, pageVO);
    }

    /**
     * 修改会员升级规则可获取的分值
     * @param headers HttpHeaders信息
     * @param ruleVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/rule/score", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberLevelRuleConfigScore(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelRuleConfigUpdateScoreVO ruleVO) {
        return memberLevelConfigService.updateMemberLevelRuleConfigScore(headers, ruleVO);
    }

    /**
     * 分页、模糊查询会员等级列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberLevelQueryVO>> pageMemberLevels(@RequestHeader HttpHeaders headers, @Valid MemberLevelPageVO pageVO) {
        return memberLevelConfigService.pageMemberLevels(headers, pageVO);
    }

    /**
     * 新增或修改会员等级时，查询等级类型列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/level/types", method = RequestMethod.GET)
    public Wrapper<List<MemberLevelTypeVO>> findMemberLevelTypes(@RequestHeader HttpHeaders headers) {
        return memberLevelConfigService.findMemberLevelTypes(headers);
    }

    /**
     * 新增会员等级时，分页查询会员角色列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/level/role/page", method = RequestMethod.GET)
    public Wrapper<PageData<RoleQueryVO>> pageRoles(@RequestHeader HttpHeaders headers, @Valid PageVO pageVO) {
        return memberLevelConfigService.pageRoles(headers, pageVO);
    }

    /**
     * 新增会员等级
     * @param headers Http头部信息
     * @param levelVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/create", method = RequestMethod.POST)
    public Wrapper<Void> createMemberLevel(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelVO levelVO) {
        return memberLevelConfigService.createMemberLevel(headers, levelVO);
    }

    /**
     * 修改会员等级
     * @param headers Http头部信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberLevel(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelUpdateVO updateVO) {
        return memberLevelConfigService.updateMemberLevel(headers, updateVO);
    }

    /**
     * 查询会员等级详细信息
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/get", method = RequestMethod.GET)
    public Wrapper<MemberLevelDetailVO> findMemberLevel(@RequestHeader HttpHeaders headers, @Valid MemberLevelIdVO idVO) {
        return memberLevelConfigService.findMemberLevel(headers, idVO);
    }

    /**
     * 更改会员等级状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/status", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberLevelStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelStatusVO statusVO) {
        return memberLevelConfigService.updateMemberLevelStatus(headers, statusVO);
    }

    /**
     * 删除会员等级
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/level/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteMemberLevel(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelIdVO idVO) {
        return memberLevelConfigService.deleteMemberLevel(headers, idVO);
    }

    /**
     * 权益与升级阈值 - 查询详情
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/right/detail", method = RequestMethod.GET)
    public Wrapper<MemberLevelRightDetailVO> findMemberLevelRightDetail(@RequestHeader HttpHeaders headers, @Valid MemberLevelIdVO idVO) {
        return memberLevelConfigService.findMemberLevelRightDetail(headers, idVO);
    }

    /**
     * 权益与升级阈值 - 选择会员权益
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/right/find", method = RequestMethod.GET)
    public Wrapper<List<BaseMemberRightQueryVO>> findMemberLevelRights(@RequestHeader HttpHeaders headers) {
        return memberLevelConfigService.findMemberLevelRights(headers);
    }

    /**
     * 修改升级阈值、权益列表
     * @param headers Http头部信息
     * @param pointVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/right/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberLevelRight(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberLevelRightUpdateVO pointVO) {
        return memberLevelConfigService.updateMemberLevelRight(headers, pointVO);
    }

    /**
     * 更改会员权益参数值
     * @param headers Http头部信息
     * @param paramVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/right/parameter/update", method = RequestMethod.POST)
    public Wrapper<Void> updateRightParameter(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberRightParamVO paramVO) {
        return memberLevelConfigService.updateRightParameter(headers, paramVO);
    }

    /**
     * 更改会员权益状态
     * @param headers Http头部新
     * @param statusVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/right/status", method = RequestMethod.POST)
    public Wrapper<Void> updateRightStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberRightStatusVO statusVO) {
        return memberLevelConfigService.updateRightStatus(headers, statusVO);
    }

    /**
     * 初始化会员等级与权益
     * @param headers Http头部信息
     * @return 操作结果
     */
    @RequestMapping(value = "/level/rebuild", method = RequestMethod.POST)
    public Wrapper<Void> rebuildMemberLevelRight(@RequestHeader HttpHeaders headers) {
        return memberLevelConfigService.rebuildMemberLevelRight(headers);
    }
}
